package com.redsoil.house.ui.capital.activity;

import android.content.Context;
import android.content.Intent;

import com.github.barteksc.pdfviewer.PDFView;
import com.redsoil.house.R;
import com.redsoil.house.base.RootActivity;
import com.redsoil.house.ui.capital.contract.PdfContract;
import com.redsoil.house.ui.capital.presenter.PdfPresenter;
import com.redsoil.house.widget.actionbar.XBaseTopBar;
import com.redsoil.house.widget.actionbar.XBaseTopBarImp;

import java.io.File;

import butterknife.BindView;

/**
 * Created by Lionel2Messi
 */
public class PdfActivity extends RootActivity<PdfPresenter> implements PdfContract.View , XBaseTopBarImp {

    @BindView(R.id.pdfView)
    PDFView pdfView;

    private String path;

    @BindView(R.id.main_topbar)
    XBaseTopBar main_topbar;

    /**
     * 打开新Activity
     *
     * @param context
     * @return
     */
    public static Intent newInstance(Context context,String path) {
        Intent intent = new Intent(context, PdfActivity.class);
        intent.putExtra("path",path);
        return intent;
    }

    @Override
    protected void initInject() {
        getActivityComponent().inject(this);
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_pdf;
    }

    @Override
    protected void initEventAndData() {

        main_topbar.setxBaseTopBarImp(this);

        path = getIntent().getStringExtra("path");
        pdfView.fromFile(new File(path))   //设置pdf文件地址
                .defaultPage(0)
                .enableSwipe(true)
                .load();
    }

    @Override
    public void responeError(String errorMsg) {

    }

    @Override
    public void left() {
        finish();
    }

    @Override
    public void right() {

    }
}